'''This is a module to give out privileges, it will give out +o or +v to 
everyone who joins a room if you ask it to.'''
############################################################################
#    Copyright (C) 2006 by Robert Small                                    #
#    SmallR2002@Gmail.com                                                  #
#                                                                          #
#    This program is free software; you can redistribute it and#or modify  #
#    it under the terms of the GNU General Public License as published by  #
#    the Free Software Foundation; either version 2 of the License, or     #
#    (at your option) any later version.                                   #
#                                                                          #
#    This program is distributed in the hope that it will be useful,       #
#    but WITHOUT ANY WARRANTY; without even the implied warranty of        #
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         #
#    GNU General Public License for more details.                          #
#                                                                          #
#    You should have received a copy of the GNU General Public License     #
#    along with this program; if not, write to the                         #
#    Free Software Foundation, Inc.,                                       #
#    59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             #
############################################################################

__module_name__        = "bcpurser"
__module_version__     = "0.0.1"
__module_description__ = "This is a module to give out privileges, it will give out +o or +v to everyone who joins a room if you ask it to."

import xchat
import sys
import os

if (sys.path.count(os.path.dirname(__file__) ) == 0):
    sys.path.append(os.path.dirname(__file__) )

#  Pretty much essential.
import bcsettings

def auto_give_privilage(word, word_eol, userdata): #IGNORE:W0613
    '''
    Gives priv's on join if it's meant to.
    @param word: all the data you need to work with, chopped up into small parts.
    @type word: string
    @param word_eol: all the data you need to work with, chopped from wherever you're starting from.
    @type word_eol: string
    @param userdata: custom object to pass back.
    @type userdata: object
    '''
    for i, w in enumerate(bcsettings.auto_op_all_in_channels):
        if (word[1].lower() == bcsettings.auto_op_all_in_channels[i].lower()) and (xchat.get_info('network') == bcsettings.auto_op_all_in_networks[i]):
            xchat.command('op ' + word[0])
            w = w    #Just to satisfy the code checker, w needs to be used in the for so that it'll be easier to get at i.
            
        #Next
    for i, w in enumerate(bcsettings.auto_voice_all_in_channels):
        if (word[1].lower() == bcsettings.auto_voice_all_in_channels[i].lower()) and (xchat.get_info('network') == bcsettings.auto_voice_all_in_networks[i]):
            xchat.command('voice ' + word[0])
            w = w    #Just to satisfy the code checker, w needs to be used in the for so that it'll be easier to get at i.
